package com.hxx.day7;

import java.util.HashMap;
import java.util.Hashtable;

/**
 * hashMap区别hashTable
 * 1.hashTable是线程安全的,hashMap是线程不安全的
 * 2.hashTable不允许key和value为null,hashMap允许key和value为null
 */
public class TestDemo9 {

    public static void main(String[] args) {
        // hashMap允许key和value为null
        HashMap<String, Object> map = new HashMap<>();
        map.put(null,"hello");

        System.out.println(map);

        // hashTable不允许key和value为null
        Hashtable<String, Object> hashtable = new Hashtable<>();
        hashtable.put(null,"hello");
        System.out.println(hashtable);
    }
}























